package com.xz.java;

/**
 * @author XZ
 * @create 2021-04-15 18:13
 */
public class Main {
    /*
    0 1 1 2 3 5 8 13 ..
     */

    public static int fib1(int n) {
        if (n <= 1) {
            return n;
        }
        return fib1(n - 1) + fib1(n - 2);
    }

    public static int fib2(int n) {
        if (n <= 1) {
            return n;
        }
        int first = 0;
        int second = 1;
        int sum = 0;
        for (int i = 0; i < n - 1; i++) {
            sum = first + second;
            first = second;
            second = sum;

        }
        return second;
    }

    public static void main(String[] args) {
    }
}
